#include <cstdio> 
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}

inline void write(long long x)
{
    if(x>=10) write(x/10);
    putchar(x%10+'0');
}
#define DEBUG
#define mod(x) (x%MOD+MOD)%MOD
using ll=long long;
using PII=pair<int, int>;
const int N=1e6+10, M=110, MOD=998244353;
int n;
int A[N];
ll ans=0;

// 计算最大公约数
int gcd(int a, int b) {
    return b==0?a:gcd(b, a%b);
}

void init()
{
	read(n);
	for(int i=1; i<=n; i++)
		read(A[i]);

}

void solve()
{
    init();
    for(int l=1; l<=n; l++)
    {
        vector<PII> gcds; //从l开始到当前位置的不同最大公约数和对应的最右位置
        gcds.emplace_back(A[l], l);
		for(int r=l; r<=n; r++)
        {
            vector<PII> newgcds;
            for(auto [pregcd, prer]:gcds)
            {
                int newGCD=gcd(pregcd, A[r]);
                if(newgcds.empty()||newgcds.back().first!=newGCD)
                    newgcds.emplace_back(newGCD, r);
            }
            gcds=newgcds;

            for(auto [val, valpos]:gcds)
            {
                ans=mod(ans+l*r*val);
            }
        }
    }
		
	write(ans); puts("");
}

signed main()
{
    #ifdef DEBUG
        freopen("../in.txt", "r", stdin);
        freopen("../out.txt", "w", stdout);
    #endif

    int T=1; //scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}